package com.lottery.im.module.service.ui;

import android.annotation.SuppressLint;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import com.lottery.im.R;
import com.lottery.im.base.BaseSwipeFragment;
import com.lottery.im.module.service.presenter.AccOutResultPresenter;
import com.lottery.im.module.service.view.AccOutResultView;

/**
 * A simple {@link Fragment} subclass.
 */
@SuppressLint("ValidFragment") public class AccOutResultFragment
    extends BaseSwipeFragment<AccOutResultPresenter>
    implements AccOutResultView {

  @BindView(R.id.tv_title) TextView tvTitle;
  @BindView(R.id.imageView) ImageView imageView;
  @BindView(R.id.tv_msg) TextView tvMsg;
  @BindView(R.id.btn_confirm) Button btnConfirm;

  private String msg;

  public interface ConfirmClick{
    void onConfirmClick();
  }
  public ConfirmClick mConfirmClick;
  public void setOnConfirmClick(ConfirmClick confirmClick){
    mConfirmClick=confirmClick;
  }

  @SuppressLint("ValidFragment") public AccOutResultFragment(String msg) {
    this.msg = msg;
  }

  @Override protected int getLayoutResId() {
    return R.layout.fragment_acc_out_result;
  }

  @Override protected void initPresenter() {
    presenter = new AccOutResultPresenter(getActivity(), this, this);
    presenter.init();
  }

  @Override public void initView() {
    tvTitle.setText("提现");
    tvMsg.setText(msg);
    if (getString(R.string.acc_out_success).equals(msg)) {
      imageView.setImageResource(R.drawable.icon_dhcg);
      btnConfirm.setText("完成");
    } else {
      imageView.setImageResource(R.drawable.fail);
      btnConfirm.setText("重新输入");
    }
  }

  @OnClick({ R.id.iv_back, R.id.btn_confirm }) public void onViewClicked(View view) {
    switch (view.getId()) {
      case R.id.iv_back:
        popBackStack();
        break;
      case R.id.btn_confirm:
        if(getString(R.string.acc_out_success).equals(msg)){
          mConfirmClick.onConfirmClick();
        }
        popBackStack();
        break;
    }
  }

}
